/** @author: duanhaijiao  @date 2022/7/5--17:15 **/

/* name: "sliderTabBar" */
<template>
    <div class="sliderTabBar">
        <img class="sliderTabBar-bg img" src="@/assets/imgs/common/sliderBar.png" alt="">
        <div class="sliderTabBar-top">
            {{title}}
        </div>
        <div class="sliderTabBar-nav-list">
            <div class="sliderTabBar-nav-item pointer" :class="selectId == item.id?'active':''" v-for="(item,index) in navList" @click="navSelect(item)">
                {{item.name}}
            </div>
        </div>
    </div>
</template>

<script>
    // @ is an alias to /src

    export default {
        name: "sliderTabBar",
        props:{
            title:{
                type:String,
                default:''
            },
            navList:{
                type:Array,
                default: []
            },
            checkedId:{
                type:String,
                default:''
            }
        },
        watch:{
            'checkedId':{
                handler(newval,oldval){
                    this.selectId = newval;
                },
                immediate:true
            }
        },
        data() {
            return {
                selectId:1
            }
        },
        mounted() {
        },
        methods: {
            navSelect(data){
                this.selectId = data.id;
                this.$emit('sliderSelect',data)
            }
        }
    };
</script>

<style lang="scss">
.sliderTabBar{
    width:160px;
    height: 700px;
    position: -webkit-sticky;
    position: sticky;
    top: 10px;
    .sliderTabBar-bg{
        width: 160px;
        height: 700px;
        position: absolute;
        z-index: -1;
    }
    .sliderTabBar-top{
        height: 60px;
        line-height: 60px;
        text-align: center;
        font-size: 18px;
        font-family: Microsoft YaHei;
        font-weight: bold;
        color: #C31924;
    }
    .sliderTabBar-nav-list{
        .sliderTabBar-nav-item{
            padding: 20px 0;
            text-align: center;
            /*background: rgb(236, 234, 234);*/
            box-shadow: 0px 1px 0px 0px #dedede;
            margin-bottom: 2px;
        }
        .sliderTabBar-nav-item.active{
            background: #245794;
            color: #f1f1f1;
        }
    }

}

</style>
